/*JQuery Validation for Array of Input Elements
 * based on jQuery Validation Plugin - v1.11.0 - 2/4/2013
 * 
 * this should be placed after jquery.validate.js
 * this enhancement solves the problem is that the current jquery.validate.js only validates 
 * the first field of the array (multiple fields with same name).
 * 
 * by Yadong Zhu 4/26/2013
 * */
(function($) {
	$.extend($.validator.prototype, {
		checkForm: function() {
			this.prepareForm();
			for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
				if (this.findByName( elements[i].name ).length != undefined && this.findByName( elements[i].name ).length > 1) {
					for (var cnt = 0; cnt < this.findByName( elements[i].name ).length; cnt++) {
						this.check( this.findByName( elements[i].name )[cnt] );
					}
				} else {
					this.check( elements[i] );
				}
			}
			return this.valid();
		}			
	});
}(jQuery));